package cn.wang.common.advice;

import cn.wang.common.Exceptions.impl.LyException;
import cn.wang.common.vo.ExceptionResult;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class CommonExceptionHandler {
    @ExceptionHandler(LyException.class)
    public ResponseEntity<ExceptionResult> exceptionHandler(LyException em){
        return ResponseEntity.status(em.getCode()).body(new ExceptionResult(em.getExceptionBaseEnum()));
    }
}
